package com.buaa.springboot.fileupload.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 统一响应体对应的响应码枚举类，所有的业务异常码均在此定义
 * 响应码编号可以按照进行业务分类
 */
@AllArgsConstructor
@Getter
public enum ResponseCode {

    //
    SUCCESS(200, "成功"),
    //认证、授权、非业务相关
    INVALID_TOKEN(401, "该用户未认证或认证已过期"),
    ACCESS_DENIED(403, "该用户没有访问权限"),
    INTERNAL_SERVER_ERROR(500, "服务器出现问题"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),

    //SQL层错误
    RECORD_EXISTED(600, "记录已存在"),

    //Web错误
    PARAMETER_MISS(402, "缺少必要参数"),
    FILE_EMPTY(710, "文件为空"),
    FILE_ERR(710, "获取文件失败"),

    //镜像相关
    IMAGE_UPLOAD_FAIL(1201,"镜像上传失败"),
    IMAGE_NOT_FOUND(1202,"镜像记录不存在"),
    IMAGE_NOT_ALLOWED(1203,"镜像操作不允许"),
    IMAGE_ALREADY_EXIST(1204,"镜像已存在"),
    IMAGE_UNCOMPRESS_FAILED(1205,"镜像解析失败"),
    IMAGE_INVALID_GIT_URL(1221,"不合法的Git仓库地址"),
    IMAGE_BUILD_FAIL(1222,"DockerBuild镜像构建失败"),
    IMAGE_PUSH_FAIL(1223,"DockerPush镜像推送失败"),

    //用户相关
    USER_ALREADY_FOUND(800, "用户名已存在"),
    ROLE_NOT_FOUND(801, "角色不存在"),
    USER_ALREADY_IS_ROLE(200, "用户已是该角色"),

    //科技资源搜索
    INVALID_SEARCH_CRITERIA(901,"非法检索语句"),
    INVALID_DATA_FIELD(902,"非法数据字段名"),
    INVALID_SORT_FIELD(903, "非法排序字段名"),
    ACCESS_DATA_FAIL(910,"获取数据失败"),

    //服务注册相关

    EMPTY_SERVICE_NAME(1001, "服务名不能为空"),
    EMPTY_FUNC_DESCRIBE(1002, "功能描述不能为空"),
    EMPTY_API_INFO(1003, "接口名、接口请求方式、接口链接不能为空"),
    WRONG_URL(1004, "url格式不正确"),


    //接口调用相关
    APIKEY_NOT_EXIST(1300,"秘钥不存在");

    //编号
    private final Integer code;
    //响应消息
    private final String msg;
}
